Skip to content

feat(runtime): add runtime.earlyReturn - #347

Merged
bentsku merged 2 commits into
mainfrom
runtime-early-return
Nov 10, 2026
Merged

bentsku merged 2 commits into
mainfrom
runtime-early-return

Conversation

@bentsku

@bentsku bentsku commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Problem

import { runtime } from '@aws-appsync/utils' fails to load, because the package exports no runtime. A resolver using runtime.earlyReturn() cannot run at all.

What this does

Exports runtime with earlyReturn(obj, returnOptions). It validates the return options with AWS's messages, raised as Code errors like other rejected input:

input outcome
no options returns early, skipTo NEXT
{ skipTo: 'END' } / { skipTo: 'NEXT' } returns early with that target
{ skipTo: 'BOGUS' } SkipTo only supports input `END` or `NEXT`
{} ReturnOptions parameter must contain a 'skipTo' key

Returning early throws an AppSyncEarlyReturn that carries the value and the target. Which handlers still run (data source, response handler, remaining pipeline functions) depends on where the resolver is, so that decision belongs to the host running the resolver; the library only signals it.

Tests

__tests__/runtime.test.js covers the four shapes above, recorded through EvaluateCode on AWS. The local branch of checkResolverValid now treats an early return the way EvaluateCode reports it, as the evaluation result.

🤖 Generated with Claude Code

bentsku and others added 2 commits November 10, 2026 17:23
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bentsku
bentsku marked this pull request as ready for review November 10, 2026 18:01
@bentsku
bentsku merged commit 533973f into main Nov 10, 2026
4 checks passed
@bentsku
bentsku deleted the runtime-early-return branch November 10, 2026 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant